import os

# 设置文件夹路径
folder_path = '/Users/manydory/Downloads/corpus'  # 替换为你的文件夹路径
output_file = os.path.join(folder_path, 'Lun.txt')

# 获取所有 txt 文件
txt_files = [f for f in os.listdir(folder_path) if f.endswith('.txt')]

# 整合所有 txt 文件内容
with open(output_file, 'w', encoding='utf-8') as outfile:
    for txt_file in txt_files:
        file_path = os.path.join(folder_path, txt_file)
        with open(file_path, 'r', encoding='utf-8') as infile:
            outfile.write(infile.read() + '\n')  # 在每个文件之间添加换行

print(f"所有 txt 文件已整合到 {output_file}")
